import java.util.*;

/**
 *
 * @author Alex & Umit
 */
public class MySet extends HashSet<String> {
    
    public MySet(){
        super();
    }

    public MySet union(MySet that){
        MySet res = new MySet();

        Iterator itthis = this.iterator();
        Iterator itthat = that.iterator();

        while(itthis.hasNext()){
            res.add((String)itthis.next());
        }
        while(itthat.hasNext()){
            String temp = (String)itthat.next();
            if(!res.contains(temp))
                res.add(temp);
        }
        
        return res;
    }

    public MySet intersection(MySet that){
        MySet res = new MySet();
        Iterator itthis = this.iterator();
        while(itthis.hasNext()){
            String temp = (String)itthis.next();
            if(that.contains(temp)){
                res.add(temp);
            }
        }
        return res;
    }

    public MySet difference(MySet that){
        MySet res = new MySet();
        Iterator itthis = this.iterator();
        while(itthis.hasNext()){
            String temp = (String)itthis.next();
            if(!that.contains(temp)){
                res.add(temp);
            }
        }
        return res;
    }

    @Override
    public String toString(){
        String res = "<MySet(";
        Iterator it = this.iterator();
        while(it.hasNext()){
            res += (String)it.next() + ",";
        }
        if(!isEmpty()){
            res = res.substring(0, res.length() - 1);
        }
        return res += ")>";
    }

}
